import PageTools from './PageTools'
import UploadExcel from './UploadExcel'
import UploadImg from '@/components/UploadImg'
import ImageHolder from '@/components/ImageHolder/index.vue'
import Lang from '@/components/Lang/index.vue'
import ScreenFull from './ScreenFull'
import store from '@/store'
export default {
  install(Vue) {
    // 可以直接在vue原型上写方法 在页面直接用this.调用例子this.fn
    Vue.prototype.fn = _ => { console.log(1) }
    Vue.component('PageTools', PageTools)
    Vue.component('UploadExcel', UploadExcel) // 注册导入excel组件
    Vue.component('UploadImg', UploadImg)
    Vue.component('ImageHolder', ImageHolder)
    Vue.component('Lang', Lang)
    Vue.component('ScreenFull', ScreenFull)

    // 注册一个全局自定义指令 `v-allow`
    Vue.directive('allow', {
      inserted: function(el, binding) {
        // el谁用指谁 binding对象内由value
        // 从vuex中取出points,
        const points = store.state.user.userInfo.roles.points
        if (!points.includes(binding.value)) {
          // 通过父节点移除自身
          el.parentNode.removeChild(el)
          // el.style.display = 'none'
        }
      }
    })
  }
}
